﻿using Volo.Abp.Authorization;
using Volo.Abp.Modularity;
using Volo.Abp.ObjectExtending;
using Volo.Abp.ObjectExtending.Modularity;
//using PermissionManagement;
using Volo.Abp.Users;
using Volo.Abp.Threading;
using UsersManagement;
using Xms.Abp.Modularity;

namespace IdentityManagement
{
    [DependsOn(
        typeof(IdentityManagementDomainSharedModule),
        typeof(UsersManagementAbstractionModule)
        //,
        //typeof(AbpAuthorizationModule),
        //typeof(AbpPermissionManagementApplicationContractsModule)
        )]
    public class IdentityManagementApplicationContractsModule : XmsModule
    {
        private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();

        public override void ConfigureServices(ServiceConfigurationContext context)
        {

        }

        public override void PostConfigureServices(ServiceConfigurationContext context)
        {
            OneTimeRunner.Run(() =>
            {
                ModuleExtensionConfigurationHelper.ApplyEntityConfigurationToApi(
                    IdentityModuleExtensionConsts.ModuleName,
                    IdentityModuleExtensionConsts.EntityNames.Role,
                    getApiTypes: new[] { typeof(IdentityRoleResult) },
                    createApiTypes: new[] { typeof(IdentityRoleCreateParameter) },
                    updateApiTypes: new[] { typeof(IdentityRoleUpdateParameter) }
                );

                ModuleExtensionConfigurationHelper.ApplyEntityConfigurationToApi(
                    IdentityModuleExtensionConsts.ModuleName,
                    IdentityModuleExtensionConsts.EntityNames.User,
                    getApiTypes: new[] { typeof(IdentityUserResult) },
                    createApiTypes: new[] { typeof(IdentityUserCreateParameter) },
                    updateApiTypes: new[] { typeof(IdentityUserUpdateParameter) }
                );
            });
        }
    }
}
